<html>
<head><meta charset="utf-8"><title>const generics; testing the syntax · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html">const generics; testing the syntax</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="163582578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163582578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163582578">(Apr 17 2019 at 17:29)</a>:</h4>
<p><span class="user-mention" data-user-id="218608">@yodal</span>  you could try some tests for the syntax alone using <code>macro_rules!</code></p>



<a name="163582665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163582665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163582665">(Apr 17 2019 at 17:30)</a>:</h4>
<p>i.e. make sure that it works syntactically but don't check semantics</p>



<a name="163582730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163582730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163582730">(Apr 17 2019 at 17:30)</a>:</h4>
<p><span class="user-mention" data-user-id="218608">@yodal</span>: do you remember how many of the tests you got passing on the main PR?<br>
was it all but one?</p>



<a name="163582770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163582770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> yodal <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163582770">(Apr 17 2019 at 17:31)</a>:</h4>
<p>yes, all but one</p>



<a name="163582783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163582783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163582783">(Apr 17 2019 at 17:31)</a>:</h4>
<p>e.g. <code>macro_rules! accept_item { ($i:item) =&gt; {} }</code> and then use <code>accept_item! { struct A&lt;const N: usize&gt;(); }</code></p>



<a name="163582832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163582832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163582832">(Apr 17 2019 at 17:31)</a>:</h4>
<p>also when writing tests, be sure to have some "combinatorial" aspects of them</p>



<a name="163582904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163582904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> yodal <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163582904">(Apr 17 2019 at 17:32)</a>:</h4>
<p>it has been a while since I last touched const generics so I don't remember what exactly was halting that one test, but I think it was something about normalization</p>



<a name="163583091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163583091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> yodal <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163583091">(Apr 17 2019 at 17:34)</a>:</h4>
<p>The <code>macro_rules!</code> idea is definitely a good one. Being able to test the syntax alone has been difficult</p>



<a name="163583222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163583222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163583222">(Apr 17 2019 at 17:36)</a>:</h4>
<p>It's something that is often forgotten: our syntax has stability independently of semantics (e.g. if semantic analysis produces an error, the syntax can still be valid and a matter of semver) due to macros.</p>



<a name="163595268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163595268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163595268">(Apr 17 2019 at 19:51)</a>:</h4>
<p><code>#[cfg(FALSE)]</code> is also a great way to test syntax alone.</p>



<a name="163599466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/const%20generics%3B%20testing%20the%20syntax/near/163599466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/const.20generics.3B.20testing.20the.20syntax.html#163599466">(Apr 17 2019 at 20:48)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span>  oh; clever!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>